package distributeFiles

import (
	"context"
	"devops-super/api/clusters/v1"
	"devops-super/internal/service"
)

// GetDirList 获取根目录列表
func (*ControllerV1) GetDirList(ctx context.Context, req *v1.DistributeFilesGetDirListReq) (res *v1.DistributeFilesGetDirListRes, err error) {
	return service.DistributeFiles().GetDirList(ctx, req.ServerKey)
}

// GetSubDirList 获取子目录列表
func (*ControllerV1) GetSubDirList(ctx context.Context, req *v1.DistributeFilesGetSubDirListReq) (res *v1.DistributeFilesGetSubDirListRes, err error) {
	return service.DistributeFiles().GetSubDirList(ctx, req.ServerKey, req.Path)
}

// DeleteDir 删除目录
func (*ControllerV1) DeleteDir(ctx context.Context, req *v1.DistributeFilesDeleteDirReq) (res *v1.DistributeFilesDeleteDirRes, err error) {
	err = service.DistributeFiles().DeleteDir(ctx, req.ServerKey, req.Path)
	return &v1.DistributeFilesDeleteDirRes{Success: err == nil}, nil
}